//
// Created by tang on 22-9-12.
//

#ifndef EXAMPLEVK_VULKAN_TRIANGLE_HPP
#define EXAMPLEVK_VULKAN_TRIANGLE_HPP

#include "app/vulkan_app_base.hpp"

namespace core::app {
    class VulkanTriangle : public VulkanApp {
    public:
        VulkanTriangle();
        ~VulkanTriangle();

    protected:
        void                    OnInitialize() override;
        void                    OnCleanup() override;
        void                    OnWindowResized() override;
        vk::DescriptorSetLayout OnCreateDescriptorSetLayout() override;
        vk::Pipeline
             OnCreateGraphicsPipeline(vk::Extent2D screen_size) override;
        void OnRecordRenderCommand(vk::CommandBuffer buffer,
                                   u32               currentFrame,
                                   u32               imageIdx,
                                   vk::Extent2D      screen_size) override;
        void OnUpdateBuffers(u32 imageIdx, u32 currentFrame) override;

    private:
        vk::UniqueShaderModule m_vert_shader;
        vk::UniqueShaderModule m_frag_shader;

        // vertex buffer
        vk::UniqueBuffer       m_vertex_buffer;
        vk::UniqueDeviceMemory m_vertex_memory;
        // index buffer
        vk::UniqueBuffer       m_index_buffer;
        vk::UniqueDeviceMemory m_index_memory;
        // uniform buffer
        using BufferMemory =
            std::tuple<vk::UniqueBuffer, vk::UniqueDeviceMemory>;
        std::vector<BufferMemory>      m_uniform_buffers;
        std::vector<vk::DescriptorSet> m_uniform_descriptor_sets;
    };
}  // namespace core::app

#endif  // EXAMPLEVK_VULKAN_TRIANGLE_HPP
